<template>
  <div>
    <div id="main" style="width: 600px; height: 400px;"></div>
  </div>
</template>

<script>
import * as echarts from 'echarts';
import { onMounted } from 'vue';

export default {
  name: 'EChartsExample',
  setup() {
    onMounted(() => {
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById('main'));

      fetch("http://127.0.0.1:5000/Ctubiao").then((e)=>{
        return e.json()
      }).then((e)=>{
        // 绘制图表
        myChart.setOption({
        title: {
          text: '技能排行榜top10'
        },
        tooltip: {},
        xAxis: {
          data: e[0]
        },
        yAxis: {},
        series: [
          {
            name: '销量',
            type: 'bar',
            data: e[1]
          }
        ]
      });
      });
    }

    );
  }
};
</script>

<style scoped>
#main {
  width: 600px;
  height: 400px;
}
</style>
